<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/10/31 0031
 * Time: 下午 6:22
 */

namespace app\admin\controller;


use controller\BasicAdmin;
use think\Db;

class Msg extends BasicAdmin
{
    public function index(){
        $type = $this->request->get('type');
        if ($type==1){
            $title = '在线留言';
        }elseif($type==2){
            $title = '培训报名';
        }elseif ($type==3){
            $title = '合作咨询';
        }elseif ($type==4){
            $title = '课程报名';
        }
        $this->title = $title;
        $db = Db::name('msg')->where(['is_deleted'=>1,'type'=>$type]);
        return parent::_list($db);
    }

    public function _data_filter(&$data){
        foreach ($data as $k=>$v){
            $data[$k]['content'] = json_decode($v['content'], true);
        }
    }

    public function del(){
        $ids = explode(',',$this->request->post('id'));
        Db::name('msg')->where('id','in',$ids)->delete();
        $this->success('删除成功','');
    }
}